﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RoleManager.aspx.cs" Inherits="System_Role"
    ValidateRequest="false" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>模块权限设置</title>
    <link href="../../CSS/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .treeContainer
    {
    overflow-y:auto;
    padding-left:10px;
    font-size:11pt;
    padding-bottom:0px;
    scrollbar-face-color:#0099cc;
    scrollbar-highlight-color:#0099cc;
    scrollbar-shadow-color:#919192;
    scrollbar-3dlight-color:#ffffff;
    scrollbar-arrow-color:#919192;
    scrollbar-track-color:#ffffff;
    scrollbar-darkshadow-color:#ffffff;
    overflow:auto;
    line-height:100%;
    padding-top:0px;
    height:100%;
    text-align:left;
    letter-spacing:1pt;
    }
    
    div#detailDiv {
      border:1px solid #5077A0;
      background-color:#EFF7FF;
      width:250px;
      height:80px;
      position:absolute;
     }
    </style>

    <script language="javascript" type="text/javascript" src="../../js/JS_selectall.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/JS_common.js"></script>

    <script language="javascript">
    function ChangeCityRightType(sltObj)
    {
        if(sltObj.value == "0")
        {
            document.getElementById("divNotSpec").style.display = "block";
            document.getElementById("divSpec").style.display = "none";
        }else if(sltObj.value == "1")
        {
            document.getElementById("divNotSpec").style.display = "none";
            document.getElementById("divSpec").style.display = "block";
        }
    }
    function initChecks()
    {
        var allInputs = document.getElementsByTagName("input");
        var allInputsCount = allInputs.length;
        for(var i=0;i<allInputsCount;i++)
        {
            var objNode = allInputs[i];
            if(objNode.type!="checkbox")
                continue;
            if(!objNode.checked)
                continue;
             if(typeof(objNode)=="undefined")
                continue;
                
            //设定父Chk状态
            setParentState(objNode);
         }
     }       
     function CheckedRoles()
     {
     
        var childrenDiv = document.getElementById("CBLRoles");
        
         if(childrenDiv == null || childrenDiv == "undefined")
            return ;
        var childrenArray = childrenDiv.children; //取得所有子控件
        for(var i = 0;i< childrenArray.length;i++)
        {
            var chk = childrenArray[i];
           if( chk== null || chk == "undefined" || chk.type!="checkbox")
                continue;
            if (chk.checked)
                return true;
                       
        }
        alert('提交失败,至少选择一个角色!');
        return false;
        
     }
     function createRole()
     {
        var divframe = document.getElementById("detailDiv");
        
        var pointX=event.clientX; 
        var pointY=event.clientY+document.documentElement.scrollTop+12;
        
        divframe.style.display = "block";
        divframe.style.top = pointY;
        divframe.style.left = pointX;
     }
     function checkRoleName()
     {
         var rolename = document.getElementById("newRoleName").value.Trim();
         var tipobj = document.getElementById("newRoleTip");
         if(rolename.length==0)
         {
             tipobj.innerHTML = "请输入角色名称";
             return false;
         }
         if(!isNumberOrEnglishOrChinese(rolename))
         {
             tipobj.innerHTML = "只允许输入中文、英文或数字";
             return false;
         }
         return true;
     }
     function editRole(thisobj)
     {
        var divframe = document.getElementById("detailDiv");
        document.getElementById("newRoleName").setAttribute("value",thisobj.previousSibling.nodeValue);
        document.getElementById("hidRoleId").setAttribute("value",thisobj.id);
        var pointX=event.clientX+10; 
        var pointY=event.clientY+document.documentElement.scrollTop+5;
        
        divframe.style.display = "block";
        divframe.style.top = pointY;
        divframe.style.left = pointX;
        return false;
     }
    </script>

</head>
<body onload="ChangeCityRightType(document.getElementById('DDLCityRightType'))">
    <form id="form1" runat="server">
        <asp:Label runat="server" ID="Tip" ForeColor="red" Font-Bold="true" Font-Size="Small" EnableViewState="false"></asp:Label>
        <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePageMethods="true">
        </asp:ScriptManager>
        <div id="MainContentCommon">          
          
              <%--  <table cellpadding="0" cellspacing="0" width="80%" style="table-layout: fixed;
                    margin-bottom: 5px">--%>
                 <table cellpadding="0" cellspacing="0" style="background-color: lightsteelblue; width: 100%; height: 24px;">                 
                    <tr>                    
                        <td colspan="2"> <%--<td colspan="3"> 原来是3，现在去掉最右边city操作--%>                        
                            <asp:Label ID="lblTabName" runat="server" Text="&gt;&gt;&gt;角色管理" CssClass="tit" Visible="false"></asp:Label>
                            <input  id="InsertRoleButton" runat="server" type="button" value="新建角色" class="flatbuttonface iconNew" onclick="createRole()"/>
                            <asp:Button ID="DelRoleButton" runat="server" OnClick="DelRoleButton_Click" CssClass="flatbuttonface iconDel" Text="选中删除" OnClientClick="return CheckedRoles();"/>
                            <%--<input type="button" value="切换到列表模式" class="flatbuttonface iconLinkGo" onclick="location.href='../../Public/commonpage.aspx?table=TAB_UserRole'"/>--%>
                        </td>
                    </tr>
                   <%-- </div>--%>                   
                    </table>  
                    <div class="con">
                    <div id="GerneralDiv">
                    <br />
                    <table cellpadding="0" cellspacing="0" width="80%" style="table-layout: fixed;
                    margin-bottom: 5px">
                    <tr>
                        <td style="width: 350px" valign="top">
                            <span style="font-weight: bold; text-align: center">角色信息</span>
                            <div id="RoleNodes" style="margin-left: 20px">
                                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT TABUSERROLECODE, USERROLENAME FROM TAB_USERROLE ORDER BY USERROLENAME">
                                </asp:SqlDataSource>
                                <asp:CheckBoxList runat="server" ID="CBLRoles" DataSourceID="SqlDataSource1" DataTextField="USERROLENAME"
                                    DataValueField="TABUSERROLECODE" AutoPostBack="true" Font-Size="Small" OnSelectedIndexChanged="CBLRoles_OnSelectedIndexChanged"
                                    RepeatLayout="Flow" Width="100%">
                                </asp:CheckBoxList>
                            </div>
                            <br />
                            <span style="font-size: small; color: Red;">注意：<br />
                                1、选择一个角色可以查看和修改该角色的权限；<br />
                                2、选择多个角色是进行多角色权限的批量重新设置</span>
                        </td>
                        <td style="width: 350px" valign="top">
                            <span style="font-weight: bold; text-align: center">功能模块权限</span>
                            <div class="treeContainer" id="divModuleRight">
                                <asp:TreeView ID="tvModuleRight" runat="server" NodeStyle-ForeColor="black" ShowCheckBoxes="All"
                                    EnableViewState="false" onclick="HandleCheckEvent()">
                                </asp:TreeView>
                            </div>
                        </td>
                        <td style="width: 350px;display:none" valign="top">
                            <span style="font-weight: bold; text-align: center">操作权限</span>
                            <div class="treeContainer">
                                <asp:DropDownList runat="server" ID="DDLCityRightType" onchange="ChangeCityRightType(this)"
                                     AutoPostBack="false">
                                    <asp:ListItem Text="普通权限设置" Value="0" Selected="True"></asp:ListItem>
                                    <asp:ListItem Text="动态权限设置" Value="1"></asp:ListItem>
                                </asp:DropDownList>
                                <div runat="server" id="divNotSpec" style="display: block;">
                                    <asp:TreeView ID="tvCityRight" ParentNodeStyle-Font-Underline="false" Font-Underline="false"
                                        NodeStyle-Font-Underline="false" runat="server" MaxDataBindDepth="2" NodeStyle-ForeColor="black"
                                        ShowCheckBoxes="All" ExpandDepth="0" EnableViewState="false" onclick="HandleCheckEvent()">
                                    </asp:TreeView>
                                </div>
                                <div runat="server" id="divSpec" style="display: none;">
                                    <asp:CheckBoxList ID="CBLOperation" runat="server">
                                    </asp:CheckBoxList>
                                    <span style="font-size: small; color: Red;">动态权限设置：<br />
                                        根据用户所在的分公司动态设置相应的操作权限。<br />
                                        例如：创建用户A，角色的操作权限为特殊权限设置中的查询权限，用户A所在的分公司是广州分公司，则用户A具有广州分公司数据的查询权限。</span>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td align="left" nowrap>
                            <asp:Button runat="server" ID="UpdateModuleRightButton" OnClick="UpdateModuleRight_Click"
                                CssClass="buttonface" Text="提  交" OnClientClick="return CheckedRoles();" CommandName="0"/>
                            <asp:Button runat="server" ID="AddModuleRightButton" OnClick="UpdateModuleRight_Click" CssClass="buttonface"
                                Text="增  加" OnClientClick="return CheckedRoles();" CommandName="1" Visible=false/>
                            <asp:Button runat="server" ID="DelModuleRightButton" OnClick="UpdateModuleRight_Click" CssClass="buttonface"
                                Text="去  除" OnClientClick="return CheckedRoles();" CommandName="2" Visible=false/>
                        </td>
                        <%--<td align="center" nowrap>
                            <asp:Button runat="server" ID="UpdateCityRightButton" OnClick="UpdateCityRight_Click"
                                CssClass="buttonface" Text="提  交" OnClientClick="return CheckedRoles();" CommandName="0"  EnableViewState="false"/>
                            <asp:Button runat="server" ID="AddCityRightButton" OnClick="UpdateCityRight_Click" CssClass="buttonface"
                                Text="增  加" OnClientClick="return CheckedRoles();" CommandName="1"/>
                            <asp:Button runat="server" ID="DelCityRightButton" OnClick="UpdateCityRight_Click" CssClass="buttonface"
                                Text="去  除" OnClientClick="return CheckedRoles();" CommandName="2" />
                        </td>--%>
                    </tr>
                </table>
             </div></div>
        </div>
                        
                        
        <div id="detailDiv" style="display:none">
        <div id="GerneralDivNoBorder">
            <table>
                <tr>
                    <td align="center">
                        角色名称
                    </td>
                    <td align="left">
                    <input type="text" id="newRoleName" name="newRoleName" value="" maxlength="25"/>
                    <input type="hidden" id="hidRoleId" name="hidRoleId" value=""/>
                    <br />
                    <span id="newRoleTip" style="font-size:small;color:Red;">请输入角色名称</span>
                    <br />
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <asp:Button ID="Button_Insert" runat="server" CssClass="buttonface" Text="保 存" OnClientClick="return checkRoleName();" OnClick="Button_Insert_Click" />
                        <input type="button" onclick="document.getElementById('detailDiv').style.display='none';" value="关 闭" class="buttonface" />
                    </td>
                </tr>
            </table>
        </div></div>
    </form>
</body>
</html>
